"""
通义千问Audio模型可以参考历史对话信息进行回复。您可以参考以下示例代码，实现多轮对话的功能。
"""
from dashscope import MultiModalConversation

messages = [
    {
        "role": "user",
        "content": [
            {"audio": "https://dashscope.oss-cn-beijing.aliyuncs.com/audios/welcome.mp3"},
            {"text": "这段音频在说什么?"},
        ]
    }
]

response = MultiModalConversation.call(model='qwen-audio-turbo-latest', messages=messages)
print("第1次回复:", response)

# 将模型回复到messages中，并添加新的用户消息
messages.append({
    'role': response.output.choices[0].message.role,
    'content': response.output.choices[0].message.content
})
messages.append({
    "role": "user",
    "content": [
        {"text": "简单介绍这家公司。"}
    ]
})

response = MultiModalConversation.call(model='qwen-audio-turbo-latest', messages=messages)
print("第2次回复:", response)